<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/1/19 0019
 * Time: 08:55
 */

use yii\helpers\Html;
use backend\controllers\DtActionFilter;
use yii\helpers\Url;
?>

<style type="text/css">
    .assetPackage2{height: 219px; box-sizing: border-box; position: relative;}
    .assetPackage2 .images img{margin-left: 2%;}
    .updateTime{position: absolute; right: 15px; bottom: 28px;}
</style>
<!-- 资产包详情  开始-->
<div class="container details">
    <div class="row">
        <div class="assetPackage col-md-8">
            <p class="details-nav"><span><a href="<?php  echo Url::toRoute('site/index',true);?>">办公大厅</a> > </span> <span><a href="<?php  echo Url::toRoute('search-package/search',true);?>">资产包管理</a> > </span> <span> 资产包详情</span></p>
            <div class="assetPackage-hs clearfix">
                <h1 class="pull-left"><?PHP echo $data['title'] ?></h1>
                <?php
                $package_state = Yii::$app->params['package_state'];
                if($data['state']>1)
                echo '<span class="pull-left" style="width: auto">'.$package_state[$data['state']].'</span>';
                ?>
            </div>
            <p class="psmall"><span>本金 : <?PHP echo Yii::$app->formatter->asDecimal($data['principal']); ?></span>
                <span>利息 : <?PHP echo Yii::$app->formatter->asDecimal($data['interest']); ?></span> <span>剩余户数 : <?PHP echo $data['hushu'] ?>户</span></p>
            <p class="psmall">持包人名称 : <?PHP echo $data['creditor'] ?></p>
            <div class=" details-btns">
                <?php
                if(DtActionFilter::checkPackage('package_package_like',$data['id'])) {
                    ?>
                    <button type="button" class="btn  details-btn  btn-focus-no like" id="flow"
                            data="flow-<?php echo $data['flow']; ?>-1" style="width: 99px;">
                        <?= ($data['flow'] == 1) ? Html::img('@web/image/projectDetails/isfocus.png', ['id' => 'flow_img', 'class' => 'pull-left ']) : Html::img('@web/image/projectDetails/focus.png', ['id' => 'flow_img', 'class' => 'pull-left ']) ?>
                        <span class="pull-left"><?= ($data['flow'] == 1) ?'已关注':'关注';?></span>
                    </button>
                    <?php
                }
                ?>
                <?php
                if(DtActionFilter::checkPackage('package_down',$data['id'])) {
                    ?>
                    <button type="button" class="btn btn-default details-btn asset-package-editing-download">
                        <img src="/image/assetPackage/download.png" class="pull-left ">
                        <span class="pull-left  ">下载报告</span>
                    </button>
                    <?php
                }
                ?>
                <?php
                if(DtActionFilter::checkPackage('package_initiation_plan',$data['id'])) {
                    ?>
                    <button type="button" class="btn btn-default details-btn"  id="asJump">
                        <img src="/image/assetPackage/synergy.png" class="pull-left ">
                        <span href="javascript:void();" class="clickTest pull-left"> <?= $isPlan?'修改协同':'发起协同'?></span><br/>
                    </button>
                    <?php
                }
                ?>

                <?php
                if ($isPlan && DtActionFilter::checkPackage('package_apply',$data['id'])){
                    if ($workflow_status==1){
                        echo <<<LX
  <button type="button" class="btn btn-default details-btn"  id="lixiang" data-toggle="modal" data-target="" >
                    <img src="/image/assetPackage/sqlx.png" class="pull-left">
                    <span href="javascript:return false;" class="pull-left" > 已申请立项</span><br/>
                </button>
LX;
                    }elseif($result==4){
                        echo <<<LX
  <button type="button" class="btn btn-default details-btn"  id="lixiang" data-toggle="modal" data-target="" >
                    <img src="/image/assetPackage/sqlx.png" class="pull-left">
                    <span href="javascript:return false;" class="pull-left" > 已立项</span><br/>
                </button>
LX;
                    }else{
                        echo <<<LX
  <button type="button" class="btn btn-default details-btn"  id="lixiang" data-toggle="modal" data-target="#AssetPackageEditing-approval" >
                    <img src="/image/assetPackage/sqlx.png" class="pull-left ">
                    <span href="javascript:void();" class="clickTest pull-left" > 申请立项</span><br/>
                </button>
LX;
                    }
                }
                ?>

                <?php
                if(DtActionFilter::checkPackage('package_permissions',$data['id'])) {
                    ?>
                    <button type="button" class="btn btn-default details-btn" data-toggle="modal" data-target="#myModal">
                        <img src="/image/assetPackage/xgfwqx.png" class="pull-left ">
                        <span class="pull-left  ">修改访问权限 </span>
                    </button>
                    <?php
                }
                ?>
            </div>
        </div>
        <div class="col-md-4 assetPackage2" style="padding-top: 50px;">
            <div class="row">
                <div class="col-md-12 pull-right images">
                    <?PHP
                    $avatar=$data['avatar'];
                    $editFlag=$data['avatar']['editFlag'];
                    foreach ($avatar as $key=>$val){
                        switch ($key) {
                            case 'owner'://上传人
                                if(empty($val['avatar'])){
                                    $val['avatar']='/image/common/hearder-user.png';
                                }
                                echo '<img style="width:47px;height:47px;" src="'.$val['avatar'].'" data-toggle="popover" data-placement="auto left" data-trigger="hover" class="pull-right bind_hover_card" title="资产包上传人" realName="'.$val['authItem']['description'].$val['realname'].'">';
                                break;
                            case 'zongjian'://总监
                                if($val){
                                    if(empty($val['avatar'])){
                                        $val['avatar']='/image/common/hearder-user.png';
                                    }
                                    echo '<img style="width:47px;height:47px;" src="'.$val['avatar'].'" data-toggle="popover" data-placement="auto left" data-trigger="hover" class="pull-right bind_hover_card" title="项目总监" realName="'.$val['authItem']['description'].$val['realname'].'">';
                                }
                                break;
                            case 'leader'://资产包负责人
                                foreach($val as $value){
                                    if(empty($value['avatar'])){
                                        $value['avatar']='/image/common/hearder-user.png';
                                    }
                                    echo '<img style="width:47px;height:47px;" src="'.$value['avatar'].'" data-toggle="popover" data-placement="auto left" data-trigger="hover" class="pull-right bind_hover_card" title="资产包负责人" realName="'.$value['authItem']['description'].$value['realname'].'">';
                                }
                                break;
                            case 'pre_evaluation'://预评估人员
                                foreach($val as $value){
                                    if(empty($value['avatar'])){
                                        $value['avatar']='/image/common/hearder-user.png';
                                    }
                                    echo '<img style="width:47px;height:47px;" src="'.$value['avatar'].'" data-toggle="popover" data-placement="auto left" data-trigger="hover" class="pull-right bind_hover_card" title="预评估人员" realName="'.$value['authItem']['description'].$value['realname'].'">';
                                }
                                break;
                            case 'due_diligence'://尽调成员
                                foreach($val as $value){
                                    if(empty($value['avatar'])){
                                        $value['avatar']='/image/common/hearder-user.png';
                                    }
                                    echo '<img style="width:47px;height:47px;" src="'.$value['avatar'].'" data-toggle="popover" data-placement="auto left" data-trigger="hover" class="pull-right bind_hover_card" title="尽调成员" realName="'.$value['authItem']['description'].$value['realname'].'">';
                                }
                                break;
                        }
                    }
                    ?>
                </div>
            </div>
            <div class="row updateTime">
                <?PHP
                    if(isset($data['updateTime'])){
                        echo '<p class="col-md-12"><span>'.$data['updateTime'][1].'</span><span>更新时间：'.$data['updateTime'][0].'前</span></p>';
                    }
                ?>
            </div>
        </div>
    </div>
</div>
<!-- 资产包详情  结束 -->

<!-- 模态窗口修改访问  开始!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel">
    <?php
    echo $this->render('modal/asset-package-editing-permissions', ['packageid' => $data['id'], 'departments' => $data['departments'], 'access' => $data['access'], 'access_users_ids' => $data['access_users_ids']]);//修改访问权限
    ?>
</div>
<!-- 公用模态窗口页面 -->
<!-- Modal -->
<div class="modal fade" id="modal_div" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel">
</div>
<!-- 1.模态窗口  结束!!!!!!!!!!!!!!!!!!!!!!!!!!! -->